package only.my.railgunys.artifact.calc;

import only.my.railgunys.artifact.ArtifactMain;
import only.my.railgunys.artifact.ArtifactSub;
import only.my.railgunys.bean.db.Artifact;
import only.my.railgunys.bean.db.PossibleFinalForm;

import java.util.List;

import static only.my.railgunys.artifact.calc.SubStatRollCalc.upgradeArtifact;

public class ArtifactCalc {
    public static List<PossibleFinalForm> upgradeToFinal(Artifact artifact){

        ArtifactSub[] subs = {ArtifactSub.initByCode(artifact.getSubStat1Type()),
                ArtifactSub.initByCode(artifact.getSubStat2Type()),
                ArtifactSub.initByCode(artifact.getSubStat3Type()),
                ArtifactSub.initByCode(artifact.getSubStat4Type())};
        ArtifactMain artifactMain = ArtifactMain.valueOf(artifact.getMainStat());

        PossibleFinalForm baseForm = new PossibleFinalForm();
        artifactMain.getMainStatUpgradeFunction().upMainStat(baseForm);
        subs[0].getSetValueFunction().setValue(baseForm,artifact.getSubStat1Value());
        subs[1].getSetValueFunction().setValue(baseForm,artifact.getSubStat2Value());
        subs[2].getSetValueFunction().setValue(baseForm,artifact.getSubStat3Value());
        subs[3].getSetValueFunction().setValue(baseForm,artifact.getSubStat4Value());
        baseForm.setEmbryo(artifact.getId());
        baseForm.setSuit(artifact.getAsKey());

        return upgradeArtifact(baseForm,subs);
    }
}
